import { Form, Button, message } from 'antd';
import { WeaDialog, WeaNewScroll, WeaInput, WeaLocaleProvider } from 'ecCom';
import CarConstant from '../../../util/CarConstant';
import { inject, observer } from 'mobx-react';
import { WeaTableNew } from 'comsMobx';

const WeaTable = WeaTableNew.WeaTable;
import '../../../style/index';
import CarUseContainerStore from '../../../stores/CarUseContainerStore';

const FormItem = Form.Item;
const getLabel = WeaLocaleProvider.getLabel;
@inject('CarUseSingtonStore')
class CarUseSingtonDialog extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      visible: false,
      carid: '',
      callback: undefined,
    };
  }

  render() {
    const { CarUseSingtonStore } = this.props;
    const { loading, sessionkey, tableStore } = CarUseSingtonStore;
    return (
      <WeaDialog
        ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@wyfr9l`}
        className="car"
        style={{ width: 800, height: 450 }}
        visible={this.state.visible}
        title={getLabel(19018, '车辆使用情况')}
        icon={CarConstant.iconClassName}
        iconBgcolor={CarConstant.iconBgColor}
        onCancel={this.close}
        buttons={[
          <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@efj20b@back`} type="primary" onClick={this.back}>{getLabel(1290, '返回')}</Button>,
          <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@odwt0y@close`} type="primary" onClick={this.close}>{getLabel(309, '关闭')}</Button>,
        ]}
      >
        <WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@pbbkn3`} ref="sc" height={450}>
          <div id="carViewDiv" style={{ paddingTop: 20 }}>
            <WeaTable
              ecId={`${this && this.props && this.props.ecId || ''}_WeaTable@5ej817`}
              loading={loading}
              comsWeaTableStore={tableStore}
              hasOrder
              needScroll
              // getColumns={ this.getNewColumns }
            />
          </div>
        </WeaNewScroll>
      </WeaDialog>
    );
  }

  // 打开页面
  open = (carid, callback) => {
    this.setState({
      visible: true,
      carid,
      callback,
    });
    const { CarUseSingtonStore } = this.props;
    CarUseSingtonStore.doTableLoading({ carid }); // 初始化列表
  }

  // 关闭页面
  close = () => {
    this.setState({
      carid: '',
      visible: false,
    });
  }
  // 返回车辆信息
  back = () => {
    this.state.callback(this.state.carid);
    this.setState({
      carid: '',
      visible: false,
    });
  }
}
export default CarUseSingtonDialog;
